﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
namespace _7._17
{
    class Program
    {
        public static int[] Mus()
        {
            int[] arr1 = new int[4];
            for (int i = 0; i < 4; ++i)
            {
                Console.Write("a[{0}]=", i);
                arr1[i] = int.Parse(Console.ReadLine());
            }
            return arr1;
        }
        public static int[] Mus2()
        {
            int[] arr2 = new int[4];
            for (int i = 0; i < 4; ++i)
            {
                Console.Write("a[{0}]=", i);
                arr2[i] = int.Parse(Console.ReadLine());
            }
            return arr2;
        }
        public static ArrayList Set1(int [] arr1,int [] arr2)
        {
            ArrayList str = new ArrayList();
            for (int i = 0; i < arr1.Length; i++)
            {
                str.Add(arr1[i]);
            }
            for (int j = 0; j < arr2.Length; j++)
            {
                int k = 0;
                while (arr2[j] != arr1[k])
                {
                    k++;
                    if (k == arr1.Length)
                    {
                        break;
                    }
                }
                if (k == arr1.Length)
                {
                    str.Add(arr2[j]);
                }
            }
            return str;
        }
        public static void Set3(ArrayList str)
        {
            foreach (int s in str)
            {
                Console.Write(s + " ");
            }
        }
         static void Main(string[] args)
        {
            Console.WriteLine("Вводим первый массив");
            int[] arr1 = Mus();
            Console.WriteLine("Вводим второй массив");
            int[] arr2 = Mus2();
            ArrayList str;
            str = Set1(arr1,arr2);
            Set3(str);

            //int[] arr1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            //int[] arr2 = new[] { 7, 8, 9 };
            //ArrayList str = new ArrayList();
            //for (int i = 0; i < arr1.Length; i++)
            //{
            //    str.Add(arr1[i]);
            //}
            //for (int j = 0; j < arr2.Length; j++)
            //{
            //    int k = 0;
            //    while (arr2[j] != arr1[k])
            //    {
            //        k++;
            //        if (k == arr1.Length)
            //        {
            //            break;
            //        }
            //    }
            //    if (k == arr1.Length)
            //    {
            //        str.Add(arr2[j]);
            //    }
            //}
            //foreach (int s in str)
            //{
            //    Console.Write(s + " ");
            //}
        }
    }
}